<template>
  <div>
    <el-tree :data="data"
             style="width: 800px;"
             show-checkbox
             :empty-text="placeholder"
             ref="tree"
             @check-change="handleCheckChange"
             :props="defaultProps"></el-tree>
    <el-button type="primary"
               @click="getCheckedData">获取</el-button>
  </div>
</template>
<script>
export default {
  name: '',
  props: {
  },
  mixins: [],
  components: {},
  data () {
    return {
      placeholder: '--',
      data: [],
      defaultProps: {
        children: 'children',
        label: 'pageName'
      }
    }
  },
  created () {
    this.data = window.router.options.routes
  },
  mounted () {
  },
  methods: {
    handleCheckChange () {
    },
    getCheckedData () {
      let tree = this.$refs.tree
      let res = tree.getCheckedNodes()
      // eslint-disable-next-line no-console
      console.log(res)
    }
  }
}
</script>
<style lang='less' scoped>
</style>
